package com.wsc.wsckeeper.components;

import java.lang.reflect.Field;

import android.app.DatePickerDialog;
import android.content.Context;
import android.view.View;
import android.widget.DatePicker;

public class ExDatePickerDialog extends DatePickerDialog {

	public ExDatePickerDialog(Context context, int theme, OnDateSetListener callBack, int year, int monthOfYear, int dayOfMonth) {
		super(context, theme, callBack, year, monthOfYear, dayOfMonth);
	}

	public ExDatePickerDialog(Context context, OnDateSetListener callBack, int year, int monthOfYear, int dayOfMonth) {
		super(context, callBack, year, monthOfYear, dayOfMonth);

		DatePicker datePicker = getDatePicker();
		try {
			// Field[] datePickerDialogFields =
			// datePicker.getClass().getDeclaredFields();
			// for (Field datePickerField : datePickerDialogFields) {
			// if ("mDayPicker".equals(datePickerField.getName()) ||
			// "mDaySpinner".equals(datePickerField.getName())) {
			// datePickerField.setAccessible(true);
			// Object dayPicker = new Object();
			// dayPicker = datePickerField.get(datePicker);
			// ((View) dayPicker).setVisibility(View.GONE);
			// }
			// }

			Field mDaySpinner = datePicker.getClass().getDeclaredField("mDaySpinner");
			if (mDaySpinner != null) {
				mDaySpinner.setAccessible(true);
				Object dayPicker = mDaySpinner.get(datePicker);
				((View) dayPicker).setVisibility(View.GONE);
			}

		} catch (IllegalArgumentException e) {
			e.printStackTrace();
		} catch (NoSuchFieldException e) {
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			e.printStackTrace();
		}
	}
}
